from django.db import models
from django.contrib.auth import get_user_model
User = get_user_model()


class Business(models.Model):
    name = models.CharField(verbose_name='业务线名称', max_length=32, help_text='业务线名称')
    pid = models.IntegerField(verbose_name='上级业务线', db_index=True, help_text='上级业务线id')
    letter = models.CharField(verbose_name='业务线简称', max_length=32, help_text='业务线简称，代号，字母为佳')
    dev_interface = models.ManyToManyField(to=User, verbose_name='开发接口人',
                                           related_name='dev_interface', help_text='开发接口人')
    op_interface = models.ManyToManyField(User, verbose_name='运维接口人',
                                          related_name='op_interface', help_text='运维接口人')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'resources_business'
        ordering = ['id']
        permissions = (
            ('view_business', 'can view business'),
        )
